<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="text" class="input">
    </div>
</body>
<script>
    var inp=document.querySelector('input');
    let isComposite=false;//控制search()触发
    function search(){
        //接口开始查询
        console.log('搜索');
    }
    inp.addEventListener('input',function(){
        if(!isComposite){
            search();
        }
    })
    inp.addEventListener('compositionstart',function (){
        console.log('start');
        isComposite=true;
    })
    inp.addEventListener('compositionend',function(){
        console.log('end');
        isComposite=false;
        //由于等待拼音字母输入结束后文本框输入事件则不监听了
        //所以在结束拼写监听中放search()
        search();
    })
</script>
</html>